﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace Might.ServiceServer.AuthenticationService {
    
    [ServiceContract]
    public interface IAuthenticationService {

        [OperationContract]
        Authentication GetAuthenticationWithException(Authentication Login);

        [OperationContract]
        Authentication GetAuthentication(Authentication Login, out MyFaultContract myFault);

        [OperationContract]
        bool NewAuthentication(Authentication Login);

        [OperationContract]
        bool DeleteAuthentication(Authentication Login);

        [OperationContract]
        bool UpdateAuthentication(Authentication LastAuth, Authentication UpdateAuth);

    }

    [DataContract]
    public class Authentication {
        string username = "Anonymous";
        string password = "";
        List<SvnRecord> svnList = new List<SvnRecord>();

        [DataMember]
        public string Username {
            get { return username; }
            set { username = value; }
        }

        [DataMember]
        public string Password {
            get { return password; }
            set { password = value; }
        }

        [DataMember]
        public List<SvnRecord> SvnList {
            get { return svnList; }
            set { svnList = value; }
        }
    }

    [DataContract]
    public class SvnRecord {
        string svnAddress = "";
        string svnUsername = "";
        string svnPassword = "";

        [DataMember]
        public string SvnAddress {
            get { return svnAddress; }
            set { svnAddress = value; }
        }
        
        [DataMember]
        public string SvnUsername {
            get { return svnUsername; }
            set { svnUsername = value; }
        }

        [DataMember]
        public string SvnPassword {
            get { return svnPassword; }
            set { svnPassword = value; }
        }

    }

    [DataContract]
    public class MyFaultContract {
     
        [DataMember]
        public string FaultType { get; set; }
        
        [DataMember]
        public string Message { get; set; }

    }

}
